import {BootMixin} from '@loopback/boot';
import {ApplicationConfig} from '@loopback/core';
import {
  RestExplorerBindings,
  RestExplorerComponent,
} from '@loopback/rest-explorer';
<% if (project.repositories) { -%>
import {RepositoryMixin} from '@loopback/repository';
<% } -%>
import {RestApplication} from '@loopback/rest';
<% if (project.services) { -%>
import {ServiceMixin} from '@loopback/service-proxy';
<% } -%>
<% if (project.apiconnect) { -%>
import {
  ApiConnectBindings,
  ApiConnectComponent,
  ApiConnectSpecOptions,
} from '@loopback/apiconnect';
<% } -%>
import path from 'path';
import {MySequence} from './sequence';

export {ApplicationConfig};

<% if (project.appClassWithMixins) { -%>
export class <%= project.applicationName %> extends BootMixin(
  <%= project.appClassWithMixins %>,
) {
<%
} else { // no optional mixins
-%>
export class <%= project.applicationName %> extends BootMixin(RestApplication) {
<% } -%>
  constructor(options: ApplicationConfig = {}) {
    super(options);

    // Set up the custom sequence
    this.sequence(MySequence);

    // Set up default home page
    this.static('/', path.join(__dirname, '../public'));

    // Customize @loopback/rest-explorer configuration here
    this.configure(RestExplorerBindings.COMPONENT).to({
      path: '/explorer',
    });
    this.component(RestExplorerComponent);
<%_ if (project.apiconnect) { -%>
    this.component(ApiConnectComponent);
    const apiConnectOptions: ApiConnectSpecOptions = {
      targetUrl: 'http://localhost:3000/',
    };
    this.configure(ApiConnectBindings.API_CONNECT_SPEC_ENHANCER).to(
      apiConnectOptions,
    );
<%_ } -%>

    this.projectRoot = __dirname;
    // Customize @loopback/boot Booter Conventions here
    this.bootOptions = {
      controllers: {
        // Customize ControllerBooter Conventions here
        dirs: ['controllers'],
        extensions: ['.controller.js'],
        nested: true,
      },
    };
  }
}
